using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       PosSyncTransferReciever.cs
*@brief      process message PosSyncTransfer
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/3/22
*/

//process PosSyncTransfer
public class OnPosSyncTransfer
{
    /// <summary>
    /// process message
    /// </summary>
    /// <param name="op">message operator</param>
    /// <param name="session_id">session identifier</param>
    /// <param name="msg_buffer">message buffer</param>
    /// <param name="msg_bytes">buffer length</param>
    public static void OnMapping(IMessageOperator op, Int32 session_id, byte[] msg_buffer, UInt32 msg_bytes)
    {
        //TODO
		possynctransfer.PosSyncTrasfer trans = ProtoNet<possynctransfer.PosSyncTrasfer>.CreateFromBytes(msg_buffer, msg_bytes);
        UsrInfoCacheUnit ucu = op.UsrInfo.GetByGateCode(trans.GateCode);
        if (ucu != null)
        {
			possync.PosSyncMain mainMsg = ProtoNet<possync.PosSyncMain>.CreateFromBytes(trans.Buffer, (UInt32)trans.Buffer.Length);
			ProtoNet<possync.PosSyncMain>.Send(ucu.SessionId, (uint)NetMessageTypes.MessageType.PosSync, mainMsg);
        }
    }
}

//register callback
partial class MessageProcTypes<ProcType, MessageProc>
{
        [MessageProcType((int)NetMessageTypes.MessageType.PosSyncTransfer)]
        public static NetMessageProcessor.NetMessageTabFunc PosSyncTransferProc = new NetMessageProcessor.NetMessageTabFunc(OnPosSyncTransfer.OnMapping);
}
